package com.calm.study;

import com.calm.study.client.ShortcutClientRpc;
import com.calm.study.client.ShortcutServerRpc;
import com.calm.study.client.ShortcutState;
import com.vaadin.shared.MouseEventDetails;

@SuppressWarnings("serial")
public class Shortcut extends com.vaadin.ui.AbstractComponent {
	// To process events from the client, we implement ServerRpc
	private ShortcutServerRpc rpc = new ShortcutServerRpc() {

		// Event received from client - user clicked our widget
		public void click(MouseEventDetails mouseDetails) {
			if (mouseDetails.isDoubleClick()) {

			} else {
				getRpcProxy(ShortcutClientRpc.class).selected();
				getState().selected = true;
			}
		}
	};

	public Shortcut() {

		// To receive events from the client, we register ServerRpc
		registerRpc(rpc);
	}

	// We must override getState() to cast the state to MyComponentState
	@Override
	protected ShortcutState getState() {
		return (ShortcutState) super.getState();
	}
}
